/***************************************************************************
 *   Copyright (c) 2008 Jürgen Riegel <juergen.riegel@web.de>              *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/

#include "pch.h"
#include <boost_signals2.hpp>
#include <Base/Console.h>
// #include <Base/Interpreter.h>

// #include "SketchObjectSF.h"
#include "SketchObject.h"
#include "SketchGeometryExtension.h"
#include "ExternalGeometryExtension.h"
#include "SolverGeometryExtension.h"
#include "GeometryFacade.h"
#include "ExternalGeometryFacade.h"
#include "Constraint.h"
#include "Sketch.h"
/*#include "ConstraintPy.h"
#include "SketchPy.h"
#include "SketchGeometryExtensionPy.h"
#include "ExternalGeometryExtensionPy.h"
#include "GeometryFacadePy.h"
#include "ExternalGeometryFacadePy.h"*/
#include "PropertyConstraintList.h"
#include "Part/App/Attacher.h"
#include "Part/App/Geometry2d.h"


namespace Sketcher {
// extern PyObject* initModule();
}

void import_part() {
        
    Part::PropertyPartShape     ::init();
    Part::PropertyGeometryList  ::init();
    Attacher::AttachEngine        ::init();
    Attacher::AttachEngine3D      ::init();
    Attacher::AttachEnginePlane   ::init();
    Attacher::AttachEngineLine    ::init();
    Attacher::AttachEnginePoint   ::init();
    Part::Feature               ::init();
    Part::FeatureExt            ::init();
    Part::FilletBase            ::init();
    Part::Part2DObject          ::init();
        // Geometry types
    Part::GeometryExtension       	::init();
    Part::GeometryPersistenceExtension	::init();
    /*Part::GeometryIntExtension    	::init();
    Part::GeometryStringExtension 	::init();
    Part::GeometryBoolExtension   	::init();
    Part::GeometryDoubleExtension 	::init();
    Part::GeometryMigrationExtension	::init();*/
    Part::Geometry                	::init();
    Part::GeomPoint               	::init();
    Part::GeomCurve               	::init();
    Part::GeomBoundedCurve        	::init();
    Part::GeomBezierCurve         	::init();
    Part::GeomBSplineCurve        	::init();
    Part::GeomConic               	::init();
    Part::GeomTrimmedCurve        	::init();
    Part::GeomArcOfConic          	::init();
    Part::GeomCircle              	::init();
    Part::GeomArcOfCircle         	::init();
    Part::GeomArcOfEllipse        	::init();
    Part::GeomArcOfParabola       	::init();
    Part::GeomArcOfHyperbola      	::init();
    Part::GeomEllipse             	::init();
    Part::GeomHyperbola           	::init();
    Part::GeomParabola            	::init();
    Part::GeomLine                	::init();
    Part::GeomLineSegment         	::init();
    Part::GeomOffsetCurve         	::init();
    Part::GeomSurface             	::init();
    Part::GeomBezierSurface       	::init();
    Part::GeomBSplineSurface      	::init();
    Part::GeomCylinder            	::init();
    Part::GeomCone                	::init();
    Part::GeomSphere              	::init();
    Part::GeomToroid              	::init();
    Part::GeomPlane               	::init();
    Part::GeomOffsetSurface       	::init();
    Part::GeomPlateSurface        	::init();
    Part::GeomTrimmedSurface      	::init();
    Part::GeomSurfaceOfRevolution 	::init();
    Part::GeomSurfaceOfExtrusion  	::init();
    // Part::Datum                   	::init();

    // Geometry2d types
    Part::Geometry2d              ::init();
    Part::Geom2dPoint             ::init();
    Part::Geom2dCurve             ::init();
    Part::Geom2dBezierCurve       ::init();
    Part::Geom2dBSplineCurve      ::init();
    Part::Geom2dConic             ::init();
    Part::Geom2dArcOfConic        ::init();
    Part::Geom2dCircle            ::init();
    Part::Geom2dArcOfCircle       ::init();
    Part::Geom2dEllipse           ::init();
    Part::Geom2dArcOfEllipse      ::init();
    Part::Geom2dHyperbola         ::init();
    Part::Geom2dArcOfHyperbola    ::init();
    Part::Geom2dParabola          ::init();
    Part::Geom2dArcOfParabola     ::init();
    Part::Geom2dLine              ::init();
    Part::Geom2dLineSegment       ::init();
    Part::Geom2dOffsetCurve       ::init();
    Part::Geom2dTrimmedCurve      ::init();
}
/* Python entry */
// PyMOD_INIT_FUNC(Sketcher)
void import_sketch()
{
    // load dependent module
    /*
    try {
        Base::Interpreter().runString("import Part");
    }
    catch(const Base::Exception& e) {
        PyErr_SetString(PyExc_ImportError, e.what());
        PyMOD_Return(nullptr);
    }

    PyObject* sketcherModule = Sketcher::initModule();

    // Add Types to module
    Base::Interpreter().addType(&Sketcher::ConstraintPy                 ::Type,sketcherModule,"Constraint");
    Base::Interpreter().addType(&Sketcher::SketchPy                     ::Type,sketcherModule,"Sketch");
    Base::Interpreter().addType(&Sketcher::ExternalGeometryExtensionPy  ::Type,sketcherModule,"ExternalGeometryExtension");
    Base::Interpreter().addType(&Sketcher::SketchGeometryExtensionPy  	::Type,sketcherModule,"SketchGeometryExtension");
    Base::Interpreter().addType(&Sketcher::GeometryFacadePy  	        ::Type,sketcherModule,"GeometryFacade");
    Base::Interpreter().addType(&Sketcher::ExternalGeometryFacadePy  	::Type,sketcherModule,"ExternalGeometryFacade");
    */


    // NOTE: To finish the initialization of our own type objects we must
    // call PyType_Ready, otherwise we run into a segmentation fault, later on.
    // This function is responsible for adding inherited slots from a type's base class.
import_part();
    Sketcher::SketchGeometryExtension	::init();
    Sketcher::ExternalGeometryExtension	::init();
    Sketcher::SolverGeometryExtension	::init();
    Sketcher::GeometryFacade	        ::init();
    Sketcher::ExternalGeometryFacade	::init();
    // Sketcher::SketchObjectSF        	::init();
    Sketcher::SketchObject          	::init();
    // Sketcher::SketchObjectPython    	::init();
    Sketcher::Sketch                	::init();
    Sketcher::Constraint            	::init();
    Sketcher::PropertyConstraintList	::init();

    Base::Console().Log("Loading Sketcher module... done\n");

    // PyMOD_Return(sketcherModule);
    
}
